//如何导入Model
const fs = require("fs");
const db = require("./config/SequelizeBase");

const MODEL_SRC_BASE = "/src/main/models/";

let files = fs.readdirSync(__dirname+MODEL_SRC_BASE);

let js_files = files.filter((f)=>{
   return f.endsWith(".js");
},files);

module.exports = {};

for (let f of js_files){
  console.log(`import model from file ${f}...`);
  let name = f.substring(0,f.length-3);
  module.exports[name] = require(__dirname+MODEL_SRC_BASE+f);
}

module.exports.sync = (options) => {
  return db.sync(options);
};
module.exports.generateId = function () {
  return db.generateId();
};
